<?php
namespace app\admin\controller;

use think\Controller;

/**
 * 后台基础类库
 * Class Base
 * @package app\admin\controller
 */
class Base extends Controller
{
    public $userGlobal = null;
    /**
     * 初始化
     */
    public function _initialize()
    {
        $loginUser = $this->isLogin();
        // 是否登录
        if (!$loginUser) {
            return $this->redirect('login/index');
        }
        $this->userGlobal = $loginUser;
        parent::_initialize(); // TODO: Change the autogenerated stub
    }

    /**
     * 判断是否登录
     * @return bool
     */
    public function isLogin() {
        // session
        $user = session(config('admin.session_user'),'',config('admin.session_user_scope'));
        if ($user && $user->id) {
            return $user;
        }
        return false;
    }
}
